package compression;

import org.xerial.snappy.Snappy;

/**
 * Created by JinMiao
 * 结论:压缩文本的话，相同内容越多，压缩率越高
 * 2017/4/18.
 */
public class TestSnappy {
    public static void main(String[] args) throws Exception {
        String input = "不相同的内容压缩率试一下试试哈哈";
        byte[] utfBytes = input.getBytes("UTF-8");
        byte[] compressed = Snappy.compress(input);
        System.out.println(utfBytes.length);
        System.out.println(compressed.length);

        aa(input);
        long start = System.currentTimeMillis();
        aa(input);
        System.out.println(System.currentTimeMillis() - start);
    }


    private static void aa(String input)throws  Exception {
        for (int i = 0; i < 1000000; i++) {
            byte[] compressed = Snappy.compress(input);
            byte[] uncompressed = Snappy.uncompress(compressed);
        }


    }
}
